package com.zjdiepu.www.commpent.mapper.dh;

import javax.annotation.Resource;

import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.stereotype.Component;

import com.zjdiepu.www.base.core.BaseMapper;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.commpent.RedisObjectClient;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.model.base.dto.SimpleDataDictionary;
import com.zjdiepu.www.model.dh.dto.DhInsurance;
/**
 * 项目名称：dpqc-parent-manager-information <br/> 
 * 类名称：YwBusinessMapper <br/>  
 * 类描述：字段转换 <br/>    
 * 创建人：xiongxiaotun <br/> 
 * 创建时间：2017年4月25日 下午5:51:41  <br/>   
 * 修改人：xiongxiaotun <br/> 
 * 修改时间：2017年4月25日 下午5:51:41   <br/>  
 * 修改备注：    <br/> 
 * @version V1.0   <br/>
 */
@Component
public class DhInsuranceVoMapper extends BaseMapper<DhInsurance>{
	@Resource
	private RedisObjectClient redisObjectClient;
	@Resource
	private ICachedDictionaryService cachedDictionaryService;

	@Override
	public void mapper(RedisConnection redisConnection,DhInsurance m) {
		if(null == m) {
			return;
		}
		
		Integer isCacel = m.getIsCacel();
		m.setIsCacelDisplay(isCacel != null && isCacel == 1 ? "是" : "否");
		Integer isLocal = m.getIsLocal();
		m.setIsLocalDisplay(isLocal != null && isLocal == 1 ? "是" : "否");
		
		Integer year = m.getYear();
		SimpleDataDictionary simpleDataDictionary1 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), year.toString(), DataDicType.INSURANT_YEAR.getCode());
		m.setYearDisplay(simpleDataDictionary1 == null ? "" : simpleDataDictionary1.getName());
		
		String typeRenewal = m.getTypeRenewal();
		SimpleDataDictionary simpleDataDictionary = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(),typeRenewal, DataDicType.INSURANT_TYPE.getCode());
		m.setTypeRenewalDisplay(simpleDataDictionary == null ? "" : simpleDataDictionary.getName());
		
		String operatorNext = m.getOperatorNext();
		SimpleDataDictionary simpleDataDictionary2 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(),operatorNext, DataDicType.INSURANCE_EMPLOYEE.getCode());
		m.setOperatorNextDisplay(simpleDataDictionary2 == null ? "" : simpleDataDictionary2.getName());
		
		String company = m.getCompanyInsurance();
		SimpleDataDictionary companyDic = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(),company, DataDicType.INSURANCE_COMPANY.getCode());
		m.setCompanyInsuranceDisplay(companyDic == null ? "" : companyDic.getName());
	}
}
